package com.llkj.qingnianguoxue.mine;

import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jm.chat.activity.fragment.ConversationListFragment;
import com.llkj.qingnianguoxue.R;
import com.llkj.qingnianguoxue.base.BaseActivity;
import com.llkj.qingnianguoxue.base.ConstantUserInfo;
import com.llkj.qingnianguoxue.base.MyApplication;
import com.llkj.qingnianguoxue.circle.MyConversationFragment;
import com.llkj.qingnianguoxue.util.KeyBoardUtil;

/**
 * 消息中心
 */
public class MessageActivity extends BaseActivity implements View.OnClickListener {
    private RelativeLayout rlSystemMsg;//系统消息
    private TextView tvNewMsg, tvDateSystem;
    private MyConversationFragment mConvListFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_message);
        setTitle("消息中心", true, TITLE_TYPE_IMG, R.drawable.icon_back, false, TITLE_TYPE_TEXT, null);

        initView();
        initListener();
    }

    private void initView() {
        initStatusbar(TSATUSBAR_TYPE_BLACK_TEXT,rlTitle,R.color.gray_bar);
        rlSystemMsg = (RelativeLayout) findViewById(R.id.rl_system);
        tvNewMsg = (TextView) findViewById(R.id.tv_new_msg);
        tvDateSystem = (TextView) findViewById(R.id.tv_msg_time);
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        mConvListFragment = new MyConversationFragment();
        fragmentTransaction.add(R.id.content_layout, mConvListFragment, "ConversationList");
        fragmentTransaction.commit();
    }

    private void initListener() {
        rlSystemMsg.setOnClickListener(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
        int num = MyApplication.getInstance().sputil.getInt(ConstantUserInfo.IS_NEW_SYS_MSG);
        if(num>0){
            tvNewMsg.setVisibility(View.VISIBLE);
        }else{
            tvNewMsg.setVisibility(View.INVISIBLE);
        }
        KeyBoardUtil.hideSoftKeyboard2(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.rl_system://系统消息
                startActivity(SystemMessageActivity.class);
                break;
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

}
